package com.chunguang.netty.comon;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

import com.chunguang.netty.domain.RequestData;

public class QueueSiglon {
	
	  
	private Queue<RequestData> queue = new ConcurrentLinkedQueue<>();
	private static class SingletonHolder{
		  //静态初始化器，由JVM来保证线程安全
		  private static QueueSiglon instance=new QueueSiglon();
		  
	}

	 private QueueSiglon(){}
	 
	 public static QueueSiglon getInstance(){
		return SingletonHolder.instance;
	 }

	public void put(RequestData requestData2) {
		queue.add(requestData2);
	}
	public RequestData get() {
		 
		return queue.size()>0?this.queue.poll():null;
	}
	public int size(){
		return queue.size();
	}
}
